/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 * <p>
 * https://www.renren.io
 * <p>
 * 版权所有，侵权必究！
 */

package com.cn.xiaonuo.tcrfinance.tcrshops.service.impl;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.xiaonuo.common.constant.Status;
import com.cn.xiaonuo.common.entity.BusinessMessage;
import com.cn.xiaonuo.core.exception.ServiceException;
import com.cn.xiaonuo.dbs.core.annotation.DataSource;
import com.cn.xiaonuo.tcrfinance.tcrorder.entity.PvPossessionGoods;
import com.cn.xiaonuo.tcrfinance.tcrorder.entity.PvTicketingRecord;
import com.cn.xiaonuo.tcrfinance.tcrorder.mapper.PvPossessionGoodsMapper;
import com.cn.xiaonuo.tcrfinance.tcrorder.mapper.PvTicketingRecordMapper;
import com.cn.xiaonuo.tcrfinance.tcrshops.entity.HpcProductResult;
import com.cn.xiaonuo.tcrfinance.tcrshops.entity.PvProduct;
import com.cn.xiaonuo.tcrfinance.tcrshops.entity.PvProductGl;
import com.cn.xiaonuo.tcrfinance.tcrshops.entity.SlGwjProduct;
import com.cn.xiaonuo.tcrfinance.tcrshops.enums.ProductTypeExceptionEnum;
import com.cn.xiaonuo.tcrfinance.tcrshops.mapper.PvOrderFormMapper;
import com.cn.xiaonuo.tcrfinance.tcrshops.mapper.PvProductGlMapper;
import com.cn.xiaonuo.tcrfinance.tcrshops.mapper.PvProductMapper;
import com.cn.xiaonuo.tcrfinance.tcrshops.mapper.SlGwjProductMapper;
import com.cn.xiaonuo.tcrfinance.tcrshops.param.*;
import com.cn.xiaonuo.tcrfinance.tcrshops.service.ProductService;
import com.cn.xiaonuo.tcrfinance.tcrshops.service.SlGwjProductService;
import com.cn.xiaonuo.tcrfinance.tcrusers.entity.PvWallet;
import com.cn.xiaonuo.tcrfinance.tcrusers.mapper.PvWalletMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;


@Service
public class SlGwjProductServiceImpl extends ServiceImpl<SlGwjProductMapper, SlGwjProduct> implements SlGwjProductService {

    @Resource
    private SlGwjProductMapper slGwjProductMapper;

    @Override
    @DataSource(name = "jyb_soole_data_hn")
    public void updateGwjProductStatus(GwjProductReqParam productReqParam) {
        Integer status = productReqParam.getStatus();
        if(status.intValue() == 3){
            slGwjProductMapper.update(null,
                    Wrappers.lambdaUpdate(SlGwjProduct.class)
                            .set(SlGwjProduct::getSoldOut, status)
                            .set(SlGwjProduct::getUpdatedAt, new Date())
                            .eq(SlGwjProduct::getId, productReqParam.getId())
            );
        }else{
            slGwjProductMapper.update(null,
                    Wrappers.lambdaUpdate(SlGwjProduct.class)
                            .set(SlGwjProduct::getSoldOut, status)
                            .set(SlGwjProduct::getUpdatedAt, new Date())
                            .eq(SlGwjProduct::getId, productReqParam.getId())
            );
        }


    }



}
